<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    086-1344444444
    3333-333
    请输入电话号码
    <input id="phone" />
    <script>
       let phone = document.getElementById('phone');
       phone.addEventListener('keypress',function(event){
        console.log(event.key);
        //1.如果输入的不是数字的的话，直接返回
        if(!isFinite(event.key)){
            event.preventDefault();//阻止输入
            return;
        }
        let currentValue = phone.value;
        if(currentValue.length>0&&currentValue.length % 3===0){
            phone.value+='-'
        }
       });
       window.addEventListener('keydown',function(event){
         if(event.ctrlKey && event.key === 's'){
            console.log('自定义保存操作');
         }
       });
       window.addEventListener('keyup',function(event){
        console.log('keyup');
       });
       window.addEventListener('keypress',function(event){
        console.log('keypress');
       });
    </script>
</body>
</html>